<?php
	class DeviceModel
	{
		public static function saveData($data)
		{
			$device_model = XConfig::getConfig();
			$device_model = $device_model['device_model'];
	
			$station = $data['station'];
			$entries = $data['entry'];
			foreach ($entries as $entry)
			{
				$device = $entry['device'];
				if (!array_key_exists($device, $device_model))
					continue;

				$data = array('time' => $entry['time'] );
				
				$fields = $device_model[$device];

				foreach ($entry as $k => $v)
				{
					if (!array_key_exists($k, $fields))
						continue;
					$data[$fields[$k]] = $v;
				}

				$data = (object)$data;

				$db = XDB::getDB('nuclide');
				
				$db->insertObject($data, $device);
			}
		}
	};
?>